<?php
namespace App\Admin\Models;
use Common\BaseModel;
class Qcate extends BaseModel
{
    protected $res;
    protected $redis_key="admin_";
    public function initialize()
    {
        parent::initialize();
        $this->setSource('f_qcate');
    }


    /**
     * @return mixed获取分类名称
     */
    public function catelist($params=[])
    {
        if(isset($params['keywords']) && !empty($params['keywords'])) {
            $condition = "name like '%{$params['keywords']}%'";
        }else{
            $condition = '';
        }
        $cate_list = $this::find(array(
            $condition
        ));
        return $cate_list;
    }



    /**
     * 根据营销id获取营销
     */
    public function find_first_by_Id($id){
        if(empty($id)){
            return '';
        }
        $cate_info = $this->findFirstById($id);
        if($cate_info){
            return $cate_info->toarray();
        }else{
            return [];
        }
    }

    public function qcate_save($params){
        $result = $this::save($params);
        if($result){
            return true;
        }else{
            return false;
        }
    }

}
